<template>
	<view style="padding: 30rpx;">
		<view>
			<view>
				<view v-if="businessList.length === 0">
					<kevy-empty :show="true" image="https://img01.yzcdn.cn/vant/empty-image-default.png" text="暂时没有商家哦~"></kevy-empty>
				</view>
				<view v-for="item in businessList" :key="item.id" style="margin-top: 20rpx;">
					<uni-card isFull="true">
						<view style="display: flex; grid-gap: 30rpx; margin-bottom: 10rpx;"
							@click="goToDetail(item.id)">
							<view style="width: 30%;">
								<image :src="item.avatar"
									style="width: 100%; height: 200rpx; border-radius: 10rpx; display: block;"></image>
							</view>
							<view
								style="flex: 1; display: flex; flex-direction: column; justify-content: space-between; grid-gap: 10rpx;">
								<view style="font-size: 36rpx; font-weight: bold;">{{ item.name }}</view>

								<view style="display: flex;  color: #666; ">
									<view style="flex: 1;">
										<text style="color: #ff9800; font-weight: bold;">{{ item.score }}分</text>
										<text style="margin-left: 10rpx;">已售:{{ item.nums }}</text>
									</view>
									<view style="flex: 1; text-align: right; font-size: 30rpx;">30分钟内送达</text>
									</view>
								</view>

								<view style="color: skyblue;">免配送费</view>

								<view style="background-color: #ffd281; color: brown; border-radius: 4rpx; width: fit-content;
									padding: 0 8rpx;">{{ item.info || '商家介绍' }}</view>

							</view>
						</view>
					</uni-card>
				</view>

			</view>


		</view>
	</view>
</template>

<script>
	export default {
		data() {
			return {
				type: '',
				businessList: [],
			}
		},
		onLoad(option) {
			this.type = option.type
			this.load()
		},
		methods: {
			goToDetail(businessId){
					uni.navigateTo({
						url: '/pages/detail/detail?businessId='+businessId
					})
			},
			load() {
				this.$request.get('/business/selectAll', {
					type: this.type,
					status: '通过'
				}).then(res => {
					this.businessList = res.data || []
					console.log(this.businessList)
				})
			}
		}
	}
</script>

<style>
	.category-item {
		flex: 1;
		display: flex;
		flex-direction: column;
		justify-content: space-between;
		align-items: center;
		grid-gap: 10rpx;
	}
</style>